<template>
    <div><input v-model="name"></div>
    <div><input v-model="password"></div>
    <p>{{ tip }}</p>
</template>

<script>
import { ref, watch, computed } from "vue";
export default {
    setup() {
        const name = ref('');
        const password = ref('');
        const tip = ref('');

        watch(password, (oldValue, newValue) => {
            // 新增字符串长度小于6位，做提示
            if (newValue.length < 6) {
                tip.value = '密码过短'
            } else {
                tip.value = ''
            }
        })
        return {
            name,
            password,
            tip,
        }
    }
}
</script>

<style></style>
